﻿using ServiceStack.Common;
using ServiceStack.ServiceInterface;
using System.Collections.Generic;
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface.ServiceModel;
using g42.Dto;
using g42.Repos;

namespace g42.Services
{

  //[Authenticate]
  public class SampleService : Service
  {
    public SampleRepository Repository { get; set; }  //Injected by IOC

    public object Post(Sample aSample)
    {
      return Repository.Store(aSample);
    }

    public object Get(SampleList request)
    {
      List<Sample> res = new List<Sample>();
      res.Add(new Sample() { Id = Guid.NewGuid(), Bezeichnung = "first" });
      res.Add(new Sample() { Id = Guid.NewGuid(), Bezeichnung = "second" });
      res.Add(new Sample() { Id = Guid.NewGuid(), Bezeichnung = "third" });
      if (!string.IsNullOrEmpty(request.Filter)) {
        res = res.Where(r => r.Bezeichnung.Contains(request.Filter)).ToList();
      }
      return res;
    }

/*
      ListSampleDto res = new ListSampleDto();
      res
      return new ListSampleDto() { new SampleDto() { Id = 14, Bezeichnung = "from repo direkt" } };
 */ 
      // return new SampleDto() { Id = 14, Bezeichnung = "from repo direkt" };

      /*
public object Get(MyModel.Product request)
{
    var value = base.Request.QueryString["key"];
}       */



    /*
    public CategoryRepository Repository { get; set; }  //Injected by IOC

    public CategoryCollectionResponse Get(CategoryQueryCollectionRequest request)
    {
      // return CategoryRepository.Fetch(request);
      return null;
    }

    
        //Meta request
        public EntityMetaDetailsResponse Get(CategoryMetaRequest request)
        {
          return Repository.GetEntityMetaDetails(this);
        }

        //DataTable request
        public DataTableResponse Post(CategoryDataTableRequest request)
        {
          return Repository.GetDataTableResponse(request);
        }

        //Collection/query request
        public CategoryCollectionResponse Get(CategoryQueryCollectionRequest request)
        {
          return Repository.Fetch(request);
        }
    
    */

  }

}

  





